<script type="text/javascript">
function confirmation()
{
var c=confirm('Click "OK" if you would like to "Reset" this control panel so that it will be reverted to the default values set by the Admin.  Click "Cancel" if you do not want to reset to the default value or if you are not sure.');
if(c)
return true;
else
return false;
}
</script>
<FORM name="frmx" enctype="multipart/form-data" METHOD="POST" ACTION="logoclips.php?sid=<?php echo $sid;?>" onsubmit="javascript: return confirmation();">
<?php include_once('ClsSebent/config.php');
?>
<b><font face="verdana" size="1" color="green">The Current Logo appears in Red Border. To select a new one Click it. Click &quot;Change Logo&quot;.</font></b><BR>
<BR><img name="prime" src="logos/<?php print($sid."_frontlogo.jpg"); ?>" style="border: 4px solid #FF0000" width="150" height="150" ><BR>
<input type="hidden" name="fname" size="20" value="<?php echo $fname;?>"/>
<br /><input type="submit" value="Change Logo" /><br/><br />
<?php
if(!($fname)=="")
{
$fname=substr(strrchr($fname,"/"),1,strlen(strrchr($fname,"/"))); 
//echo $fname;
//move the selected file to logos folder.
if(!copy("logoclips/".$fname, "logos/".$sid."_frontlogo.jpg"))
	{?>
	<script type="text/javascript">
	alert('sorry! The selected logo will not be changed.');
	</script>	
	<?php }
	/*else
	{
		if(! chmod("logos/".$sid."_frontlogo.jpg", 0777))
		{echo "";}
	}*/
$sql="UPDATE site_home SET  logo='".$sid."_frontlogo.jpg' WHERE id=".$sid;
		//echo $sql;
		mysql_query($sql);
		?>
	<script type="text/javascript">
	alert('The logo has been changed.');
	window.close('logoclips.php');
	</script>	
	<?php 
}
$selected="";
$imgcnt=0;
$x=1;
$hnd=opendir("./logoclips");
while($file=readdir($hnd))
{	
	$imgcnt++;	
//	$flag=strcmp($file$clogo);
	$ext=substr($file, -3,3);
	if($ext=="jpg" || $ext=="gif")	
	{ ?>	
	<img name="logo<?php echo $x;?>" src="logoclips/<?php echo $file;?>" style="border: 0px solid #111111" width="150" height="150" onclick="javascript: document.frmx.fname.value=this.src; changestyle(this.name);">	
	<?php $x++; }
	else
		$imgcnt--;
	if($imgcnt==4){$imgcnt=0;print("<BR>");};
}
closedir($hnd);
?>
</FORM>
<script type="text/javascript">
function changestyle(myname)
{
var emNodes = document.getElementsByTagName('img')
var max = emNodes.length
for(var i = 0;i < max;i++)
   {
   var nodeObj = emNodes.item(i)
	   if(nodeObj.name!="prime" && nodeObj.name==myname)
	   {
	   //alert(nodeObj.name);
	   nodeObj.style.border ="4px solid #0000FF";
	   //alert(nodeObj.border);
	   //alert(document.frmx.fname.value);
	   }
   }   
}
</script>